From: Mark A. Hershberger Date: Wed, 23 Jun 2010 01:08:34 +0000 (+0000) Subject: * Adapt install.php to a more “traditional” maintenance-style script so it can extend... X-Git-Tag: 1.31.0-rc.0~36413 X-Git-Url: http://git.cyclocoop.org//%22http:/%22.attribut_html%28%24lesurls%5B%24numero%5D%29.%22/%22?a=commitdiff_plain;h=e3644ae2c4285a733c3971f8ef7a915ee405869f;p=lhc%2Fweb%2Fwiklou.git * Adapt install.php to a more “traditional” maintenance-style script so it can extend and use Maintenance class convenience methods. * Add CliInstaller class and put it in the autoloads. --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2c4598dbf3..4732d77779 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -413,6 +413,7 @@ $wgAutoloadLocalClasses = array( 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php', # includes/installer + 'CliInstaller' => 'includes/installer/CliInstaller.php', 'Installer' => 'includes/installer/Installer.php', 'InstallerDBType' => 'includes/installer/InstallerDBType.php', 'LBFactory_InstallerFake' => 'includes/installer/Installer.php', diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php new file mode 100644 index 0000000000..307762ee98 --- /dev/null +++ b/includes/installer/CliInstaller.php @@ -0,0 +1,52 @@ +setVar( '_UserLang', $option['lang'] ); + $wgContLang = Language::factory( $option['lang'] ); + $wgLang = Language::factory( $option['lang'] ); + $wgLanguageCode = $option['lang']; + } + + $this->setVar( 'wgSitename', $siteName ); + if ( $admin ) { + $this->setVar( '_AdminName', $admin ); + } else { + $this->setVar( '_AdminName', wfMsgForContent( 'config-admin-default-username' ) ); + } + } + + /** + * Main entry point. + */ + function execute( ) { + var_dump($this->getVar('_AdminName')); + } + + function showMessage( $msg /*, ... */ ) { + echo "Message: $msg\n"; + } + + function showStatusError( $status ) { + echo "Error: $status\n"; + } +} diff --git a/maintenance/install.php b/maintenance/install.php index 96afcf7fca..d68ae27659 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -1,49 +1,58 @@ addArg( 'name', 'The name of the wiki', true); + $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', false); + $this->addOption( 'pass', 'The password for the wiki administrator. You will be prompted for this if it isn\'t provided', false, true); + /* $this->addOption( 'email', 'The email for the wiki administrator', false, true); */ + $this->addOption( 'lang', 'The language to use (en)', false, true ); + /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */ + $this->addOption( 'db-type', 'The type of database (mysql)', false, true ); + /* $this->addOption( 'db-host', 'The database host (localhost)', false, true ); */ + /* $this->addOption( 'db-port', 'The database port (3306 for mysql, 5432 for pg)', false, true ); */ + $this->addOption( 'db-name', 'The database name (my_wiki)', false, true ); + $this->addOption( 'db-path', 'The path for the SQLite DB (/var/data)', false, true ); + /* $this->addOption( 'db-schema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */ + /* $this->addOption( 'db-tsearch2-schema', 'The schema for the tsearch2 DB in pg (public)', false, true ); */ + /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */ + } + + public function execute() { + $installer = new CliInstaller( $this->mArgs[0], $this->mArgs[1], $this->mOptions ); + + $installer->execute(); + } } -require_once( "$IP/includes/ProfilerStub.php" ); -require_once( "$IP/includes/Defines.php" ); -require_once( "$IP/includes/GlobalFunctions.php" ); -require_once( "$IP/includes/AutoLoader.php" ); -require_once( "$IP/includes/Hooks.php" ); -require_once( "$IP/includes/DefaultSettings.php" ); -require_once( "$IP/includes/Namespace.php" ); - -$wgContLang = Language::factory( 'en' ); // will be overridden later - -// Disable the i18n cache and LoadBalancer -Language::getLocalisationCache()->disableBackend(); -LBFactory::disableBackend(); - -$installer = new CliInstaller( $argv ); - -$langCode = 'en'; - -$wgLang = Language::factory( $langCode ); - -$wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT]; - -$session = $installer->execute( $argv ); - -$_SESSION['installData'] = $session; +$maintClass = "CommandLineInstaller"; +require_once( DO_MAINTENANCE );